Skip to content

test(cli): keep the Windows service tests out of the real state directory - #352

Merged
T-Crypt merged 1 commit into
mainfrom
T-Crypt/windows-tests-temp-state
Nov 16, 2026
Merged

T-Crypt merged 1 commit into
mainfrom
T-Crypt/windows-tests-temp-state

Conversation

@T-Crypt

@T-Crypt T-Crypt commented Nov 16, 2026

Copy link
Copy Markdown
Owner

Closes #351.

What changes

TestServiceUninstallWindows, TestServiceUninstallWindowsIgnoresEndFailure and TestServiceInstallWindowsCommandFails did not set XDG_STATE_HOME. defaultStateDir() fell back to the user's own .local\state\berth. The fake ops replace only the schtasks calls, so the uninstall's os.Remove of each unit's stub ran for real. On a machine with Berth installed, go test ./internal/cli deleted berthd.vbs, berth-gateway.vbs and berth-harbor.vbs.

Each of the three tests now gets a temporary state directory, as the other tests in the file already do. TestServiceInstallWindowsCommandFails was not in the report. Its fake fails every schtasks call, so it does not write today, but it had the same gap.

Proof

  • I ran the Windows test binary under wine with stubs placed in the wine profile's state directory. Before the change, the uninstall tests deleted all three stubs. After it, the whole internal/cli package leaves them in place and writes nothing else there.
  • Full proof is green: build, gofmt, vet, go test ./..., the Windows build and vet, golangci-lint 2.14.0. The windows CI job runs the tests on Windows.

…tory

TestServiceUninstallWindows, TestServiceUninstallWindowsIgnoresEndFailure
and TestServiceInstallWindowsCommandFails did not set XDG_STATE_HOME, so
defaultStateDir fell back to the user's own state directory. The fake ops
stand in for schtasks only, and the uninstall's os.Remove of each unit's
stub was real: go test on a live Windows install deleted berthd.vbs,
berth-gateway.vbs and berth-harbor.vbs. Each test now uses a temporary
state directory, as the rest of the file does.

Reproduced under wine with stubs planted in the profile's state
directory: removed before, kept after, across the whole cli package.

Closes #351
@T-Crypt
T-Crypt merged commit 13952aa into main Nov 16, 2026
2 checks passed
@T-Crypt
T-Crypt deleted the T-Crypt/windows-tests-temp-state branch November 16, 2026 20:08
T-Crypt added a commit that referenced this pull request Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

go test on a live Windows install deletes the production unit stubs (TestServiceUninstallWindows* missing XDG_STATE_HOME)

1 participant